package com.it.btyw


import android.app.Application
import android.content.Context
import com.it.common.crash.CrashExceptionHandler
import com.it.common.utils.LogUtil
import com.it.common.utils.TtsUtil
import com.it.common.utils.XLogUtils
import com.it.data.manager.AppManager
import com.tencent.mmkv.MMKV
import com.xuexiang.xupdate.XUpdate
import me.jessyan.autosize.AutoSize


/**
 *  @Description：
 *  @author：weishixiong
 *  @date：2023/3/27 18:01
 *
 */
class HmApplication : Application() {

    companion object {
        const val TAG = "HmApplication"
    }

    override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        xcrash.XCrash.init(this)
    }

    override fun onCreate() {
        super.onCreate()
        XLogUtils.xLogInit(this)
        Thread.setDefaultUncaughtExceptionHandler(CrashExceptionHandler(this))
        init()
    }

    private fun init() {
        AppManager.appContext = this
        AutoSize.initCompatMultiProcess(this)
        val rootDir = MMKV.initialize(this)
        LogUtil.d(TAG, "rootDir: $rootDir")
        TtsUtil.getInstance().init(this)
        initXUpdate()
        LogUtil.clearFormerLogs()


    }

    private fun initXUpdate() {
        XUpdate.get()
            .init(this)
    }


}